import API from "@/utils/request"

export function login(user) {
    return API.post('/user/login', user)
}

export function register(user){
    return API.post('/user/register',user)
}

export function checkNameExists(username){
    return API.get('/user/checkName',{params:{username}})
}

export function refreshToken(){
    return API.get('/user/refreshToken')
}

// data:{'username','password','phone'}
export function resetPwd(data){
    return API.put('/user/reset',data)
}

export function getPageUser({pageNum,pageSize,name}){
    return API.get('/user/page',{
        params:{
            pageNum,
            pageSize,
            name
        }
    })
}

export function getAllUser(){
    return API.get('/user')
}

export function getUserById(id){
    return API.get(`/user/${id}`)
}

export function saveUser(User){
    return API.post('/user',User)
}

export function updateUser(User){
    return API.put('/user',User)
}

export function removeUser(id){
    return API.delete(`/user/${id}`)
}

//修改用户的余额
export function changeAccount(money){
    return API.put(`/user/account/${money}`)
}